package com.hefeng.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hefeng.domain.WxUserMessage;
import com.hefeng.service.IWxUserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hefeng.common.log.annotation.Log;
import com.hefeng.common.log.enums.BusinessType;
import com.hefeng.common.security.annotation.RequiresPermissions;
import com.hefeng.common.core.web.controller.BaseController;
import com.hefeng.common.core.web.domain.AjaxResult;
import com.hefeng.common.core.utils.poi.ExcelUtil;
import com.hefeng.common.core.web.page.TableDataInfo;

/**
 * 用户消息日志Controller
 *
 * @author ruoyi
 * @date 2022-09-06
 */
@RestController
@RequestMapping("/message")
public class WxUserMessageController extends BaseController {
    @Autowired
    private IWxUserMessageService wxUserMessageService;

    /**
     * 查询用户消息日志列表
     */
    @RequiresPermissions("system:message:list")
    @PostMapping("/list")
    public TableDataInfo list(WxUserMessage wxUserMessage) {
        startPage();
        List<WxUserMessage> list = wxUserMessageService.selectWxUserMessageList(wxUserMessage);
        return getDataTable(list);
    }


    /**
     * 获取用户消息日志详细信息
     */
    @RequiresPermissions("system:message:query")
    @PostMapping(value = "/{messageId}")
    public AjaxResult getInfo(@PathVariable("messageId") Long messageId) {
        return AjaxResult.success(wxUserMessageService.selectWxUserMessageByMessageId(messageId));
    }

    /**
     * 新增用户消息日志
     */
    @RequiresPermissions("system:message:add")
    @Log(title = "用户消息日志", businessType = BusinessType.INSERT)
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody WxUserMessage wxUserMessage) {
        return toAjax(wxUserMessageService.insertWxUserMessage(wxUserMessage));
    }

    /**
     * 修改用户消息日志
     */
    @RequiresPermissions("system:message:edit")
    @Log(title = "用户消息日志", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody WxUserMessage wxUserMessage) {
        return toAjax(wxUserMessageService.updateWxUserMessage(wxUserMessage));
    }

    /**
     * 删除用户消息日志
     */
    @RequiresPermissions("system:message:remove")
    @Log(title = "用户消息日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{messageIds}")
    public AjaxResult remove(@PathVariable Long[] messageIds) {
        return toAjax(wxUserMessageService.deleteWxUserMessageByMessageIds(messageIds));
    }
}
